//
//  YMNetworkManager.swift
//  ChengLuMall
//
//  Created by 吳梓杭 on 2023/5/28.
//

import Foundation
import Alamofire

class YMNetworkManager {
    
    static let shared: YMNetworkManager = {
        let shared = YMNetworkManager()
//        shared.setReachabilityStatusMonitoring()
        return shared
    }()
    // 网络状态
    var status: NetworkReachabilityManager.NetworkReachabilityStatus = .unknown
    /// 弹窗选择器是否显示
    public var isShowAlert: Bool = false
     
    private var isNotReachable: Bool = false
    
//    /// 网络监听
//    public func setReachabilityStatusMonitoring() -> Void {
//        let manager = NetworkReachabilityManager.default
//        manager?.startListening(onUpdatePerforming: { status in
//            self.status = status
//            let vc = QMUIHelper.visibleViewController() ?? UIViewController()
//            var statusString: String?
//            switch status {
//            case .notReachable:
//                statusString = "网络异常"
//                self.isNotReachable = true
//            case .reachable(.ethernetOrWiFi):
//                statusString = "WIFI"
//                fallthrough
//            case .reachable(.cellular):
//                statusString = "蜂窝网络"
//                if self.isNotReachable {
//                    var params = [String : Any]()
//                    params["vc"] = NSStringFromClass(type(of: vc.self))
//                    NotificationCenterPost(name: Notification.Name(kNetworkBackUpNotification), object: params)
//                    self.isNotReachable = false
//                }
//            case .unknown:
//                fallthrough
//            default:
//                statusString = "未知网络"
//            }
//            NotificationCenterPost(name: Notification.Name(rawValue: kReachabilityStatusMonitoringNotification), object: status)
//#if DEBUG
//            print(message: statusString)
//            SVProgressHUD.showText(statusString)
//#endif
//        })
//    }
    
}
